import request from '@/utils/request';

export async function fetchGroupTree(params) {
  return request('/amaidan-sys-user/merchants/sysGroup/listTree', {
    method: 'POST',
    data: params,
  });
}

export async function fetchGroups(params) {
  return request('/amaidan-sys-user/merchants/sysGroup/list', {
    method: 'POST',
    data: params,
  });
}

export async function GroupBindingUser(params) {
  return request('/amaidan-sys-user/merchants/sysGroup/binding', {
    method: 'POST',
    data: params,
  });
}

export async function addGroup(params) {
  return request('/amaidan-sys-user/merchants/sysGroup/add', {
    method: 'POST',
    data: params,
  });
}

export async function editGroup(params) {
  return request('/amaidan-sys-user/merchants/sysGroup/update', {
    method: 'POST',
    data: params,
  });
}

export async function delGroup(params) {
  return request('/amaidan-sys-user/merchants/sysGroup/delete', {
    method: 'POST',
    data: params,
  });
}

export async function fetchGroupType(type, params) {
  const url = {
    2: '/Amaidan-Merchants-Web/merchants/busMerchantsInfo/all', //商户
    3: '/Amaidan-Merchants-Web/merchants/busMerchantsInfo/all', // 供应商
    4: '/Amaidan-Merchants-Web/merchants/busMerchantsInfo/all', // 门店
    0: '/Amaidan-Merchants-Web/merchants/busMerchantsInfo/all', // 门店
    6: '/Amaidan-Merchants-Web/merchants/busAgentsInfo/list', // 代理商
    7: '/Amaidan-Merchants-Web/merchants/busMerchantsInfo/all', // 门店
    8: '/Amaidan-Merchants-Web/merchants/busOperatorInfo/getOperatorList', // 运营商
  }
  return request(url[type], {
    method: 'POST',
    data: params,
  });
}